﻿using System;
using SharpSqlAnalyzer.nodes;
using SharpSqlAnalyzer.nodes.oracle;

namespace SharpSqlAnalyzer.stmt.oracle
{
	// Token: 0x02000137 RID: 311
	public class TPlsqlCreateProcedure : TCommonStoredProcedureSqlStatement
	{
		// Token: 0x170001D5 RID: 469
		// (get) Token: 0x06000A23 RID: 2595 RVA: 0x00304726 File Offset: 0x00302926
		// (set) Token: 0x06000A22 RID: 2594 RVA: 0x0030471D File Offset: 0x0030291D
		public virtual TInvokerRightsClause InvokerRightsClause
		{
			get
			{
				return this.invokerRightsClause;
			}
			set
			{
				this.invokerRightsClause = value;
			}
		}

		// Token: 0x170001D6 RID: 470
		// (get) Token: 0x06000A24 RID: 2596 RVA: 0x0030472E File Offset: 0x0030292E
		public override TObjectName StoredProcedureName
		{
			get
			{
				return this.procedureName;
			}
		}

		// Token: 0x170001D7 RID: 471
		// (get) Token: 0x06000A26 RID: 2598 RVA: 0x0030473F File Offset: 0x0030293F
		// (set) Token: 0x06000A25 RID: 2597 RVA: 0x00304736 File Offset: 0x00302936
		public virtual int Kind
		{
			get
			{
				return this.kind;
			}
			set
			{
				this.kind = value;
			}
		}

		// Token: 0x170001D8 RID: 472
		// (get) Token: 0x06000A27 RID: 2599 RVA: 0x00304747 File Offset: 0x00302947
		// (set) Token: 0x06000A28 RID: 2600 RVA: 0x0030474F File Offset: 0x0030294F
		public virtual TObjectName ProcedureName
		{
			get
			{
				return this.procedureName;
			}
			set
			{
				this.procedureName = value;
			}
		}

		// Token: 0x06000A29 RID: 2601 RVA: 0x00304758 File Offset: 0x00302958
		public TPlsqlCreateProcedure(EDbVendor dbvendor) : base(dbvendor)
		{
			this.sqlstatementtype = ESqlStatementType.sstplsql_createprocedure;
		}

		// Token: 0x170001D9 RID: 473
		// (get) Token: 0x06000A2A RID: 2602 RVA: 0x00304770 File Offset: 0x00302970
		// (set) Token: 0x06000A2B RID: 2603 RVA: 0x0030478B File Offset: 0x0030298B
		public virtual TStatementList InnerStatements
		{
			get
			{
				if (this.innerStatements == null)
				{
					this.innerStatements = new TStatementList();
				}
				return this.innerStatements;
			}
			set
			{
				this.innerStatements = value;
			}
		}

		// Token: 0x06000A2C RID: 2604 RVA: 0x00304794 File Offset: 0x00302994
		internal override void buildsql()
		{
		}

		// Token: 0x06000A2D RID: 2605 RVA: 0x00304796 File Offset: 0x00302996
		internal override void clear()
		{
		}

		// Token: 0x06000A2E RID: 2606 RVA: 0x00304798 File Offset: 0x00302998
		internal override string getasprettytext()
		{
			return "";
		}

		// Token: 0x06000A2F RID: 2607 RVA: 0x0030479F File Offset: 0x0030299F
		internal virtual void iterate(TVisitorAbs pvisitor)
		{
		}

		// Token: 0x170001DA RID: 474
		// (get) Token: 0x06000A30 RID: 2608 RVA: 0x003047A1 File Offset: 0x003029A1
		// (set) Token: 0x06000A31 RID: 2609 RVA: 0x003047A9 File Offset: 0x003029A9
		public virtual TCallSpec CallSpec
		{
			get
			{
				return this.callSpec;
			}
			set
			{
				this.callSpec = value;
			}
		}

		// Token: 0x06000A32 RID: 2610 RVA: 0x003047B4 File Offset: 0x003029B4
		public override int doParseStatement(TCustomSqlStatement psql)
		{
			if (this.rootNode == null)
			{
				return -1;
			}
			if (base.doParseStatement(psql) != 0)
			{
				return -1;
			}
			TCreateProcedureSqlNode tcreateProcedureSqlNode = (TCreateProcedureSqlNode)this.rootNode;
			this.kind = tcreateProcedureSqlNode.Kind;
			this.callSpec = tcreateProcedureSqlNode.CallSpec;
			this.LabelName = tcreateProcedureSqlNode.LabelName;
			this.EndLabelName = tcreateProcedureSqlNode.EndLabelName;
			this.procedureName = tcreateProcedureSqlNode.ProcedureName;
			base.DatabaseObjects.Add(this.procedureName);
			this.ParameterDeclarations = tcreateProcedureSqlNode.Parameters;
			this.invokerRightsClause = tcreateProcedureSqlNode.InvokerRightsClause;
			if (this.ParameterDeclarations != null)
			{
				for (int i = 0; i < this.ParameterDeclarations.size(); i++)
				{
					this.TopStatement.SymbolTable.Push(new TSymbolTableItem(9, this, this.ParameterDeclarations.getParameterDeclarationItem(i)));
				}
			}
			if (tcreateProcedureSqlNode.InnerStmts != null)
			{
				tcreateProcedureSqlNode.InnerStmts.doParse(this, ESqlClause.unknown);
				for (int j = 0; j < tcreateProcedureSqlNode.InnerStmts.size(); j++)
				{
					this.InnerStatements.add(tcreateProcedureSqlNode.InnerStmts.getStatementSqlNode(j).Stmt);
				}
			}
			if (tcreateProcedureSqlNode.DeclareStmts != null)
			{
				tcreateProcedureSqlNode.DeclareStmts.doParse(this, ESqlClause.unknown);
				for (int k = 0; k < tcreateProcedureSqlNode.DeclareStmts.size(); k++)
				{
					this.TopStatement.SymbolTable.Push(new TSymbolTableItem(10, this, tcreateProcedureSqlNode.DeclareStmts.getStatementSqlNode(k).Stmt));
					this.DeclareStatements.add(tcreateProcedureSqlNode.DeclareStmts.getStatementSqlNode(k).Stmt);
				}
			}
			if (tcreateProcedureSqlNode.Stmts != null)
			{
				tcreateProcedureSqlNode.Stmts.doParse(this, ESqlClause.unknown);
				for (int l = 0; l < tcreateProcedureSqlNode.Stmts.size(); l++)
				{
					this.BodyStatements.add(tcreateProcedureSqlNode.Stmts.getStatementSqlNode(l).Stmt);
				}
			}
			if (tcreateProcedureSqlNode.ExceptionClause != null)
			{
				tcreateProcedureSqlNode.ExceptionClause.doParse(this, ESqlClause.unknown);
				this.ExceptionClause = tcreateProcedureSqlNode.ExceptionClause;
			}
			if (tcreateProcedureSqlNode.DeclareStmts != null)
			{
				for (int m = 0; m < tcreateProcedureSqlNode.DeclareStmts.size(); m++)
				{
					this.TopStatement.SymbolTable.Pop();
				}
			}
			if (this.ParameterDeclarations != null)
			{
				for (int n = 0; n < this.ParameterDeclarations.size(); n++)
				{
					this.TopStatement.SymbolTable.Pop();
				}
			}
			return 0;
		}

		// Token: 0x06000A33 RID: 2611 RVA: 0x00304A14 File Offset: 0x00302C14
		public override void init(object arg1)
		{
		}

		// Token: 0x06000A34 RID: 2612 RVA: 0x00304A16 File Offset: 0x00302C16
		public override void accept(TParseTreeVisitor v)
		{
			v.preVisit(this);
			v.postVisit(this);
		}

		// Token: 0x06000A35 RID: 2613 RVA: 0x00304A28 File Offset: 0x00302C28
		public override void acceptChildren(TParseTreeVisitor v)
		{
			v.preVisit(this);
			if (this.ParameterDeclarations != null)
			{
				this.ParameterDeclarations.acceptChildren(v);
			}
			if (this.InnerStatements.size() > 0)
			{
				this.InnerStatements.acceptChildren(v);
			}
			if (this.DeclareStatements.size() > 0)
			{
				this.DeclareStatements.acceptChildren(v);
			}
			if (this.BodyStatements.size() > 0)
			{
				this.BodyStatements.acceptChildren(v);
			}
			if (this.ExceptionClause != null)
			{
				this.ExceptionClause.acceptChildren(v);
			}
			v.postVisit(this);
		}

		// Token: 0x04001272 RID: 4722
		private TInvokerRightsClause invokerRightsClause;

		// Token: 0x04001273 RID: 4723
		private int kind = 1;

		// Token: 0x04001274 RID: 4724
		private TObjectName procedureName;

		// Token: 0x04001275 RID: 4725
		private TStatementList innerStatements;

		// Token: 0x04001276 RID: 4726
		private TCallSpec callSpec;
	}
}
